﻿using MainForm;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ClassLibrary;

namespace Forms
{
    public partial class ThemeColor : UIForm
    {
        User user;
        UserService userService = new UserService();
        public ThemeColor(User user)
        {
            InitializeComponent();
            this.user = user;
            Color userColor = MainForm.MainForm.userColor;
            UIStyles.InitColorful(userColor, Color.White);
        }

        private void uiColorPicker1_Click(object sender, EventArgs e)
        {
            UIStyles.InitColorful(uiColorPicker1.Value, Color.White);
        }

        private void test_Btn_Click(object sender, EventArgs e)
        {
            UIStyles.InitColorful(uiColorPicker1.Value, Color.White);
            test_Btn.Visible = true;
        }

        private void recover_btn_Click(object sender, EventArgs e)
        {
            if (uiColorPicker1.Value == MainForm.MainForm.userColor)
            {
                ShowInfoTip("主题颜色还没有更改！");
                return;
            }
            UIStyles.InitColorful(MainForm.MainForm.userColor, Color.White);
            recover_btn.Visible = true;
        }

        private void save_btn_Click(object sender, EventArgs e)
        {
            user.UserColor = uiColorPicker1.Value.ToArgb().ToString();
            userService.ModifyUser(user);
            MainForm.MainForm.userColor = uiColorPicker1.Value;
            ShowSuccessDialog("提示", "颜色保存成功！", UIStyle.Colorful);
        }
    }
}
